package com.platform.wechat.controller;

import com.platform.wechat.common.JsonBean;
import com.platform.wechat.service.HospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @program: wechat114
* @description: 医院信息控制层
* @author: MaYongQiang
* @create: 2021-07-28 13:44
*/
@RestController
@RequestMapping("Hospital")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;
    /**
    * @Description: 查询全部医院信息
    * @return: com.platform.wechat.common.JsonBean
    * @Author: MaYongQiang
    * @Date: 2021/7/28
    * @time: 13:46
    */
    @RequestMapping("HospitalInfo")
    public JsonBean getHospitalInfoOrByAddress(String hospitalAddress){
        JsonBean jsonBean = hospitalService.selectAllHospital(hospitalAddress);
        return jsonBean;
    }

    /**
    * @Description:  根据医院id查询
    * @Param: [hospitalId]
    * @return: com.platform.wechat.common.JsonBean
    * @Author: MaYongQiang
    * @Date: 2021/7/28
    * @time: 14:03
    */
    @RequestMapping("HospitalById")
    public JsonBean getHospitalById(Integer hospitalId){
        JsonBean jsonBean = hospitalService.selectHospitalMsg(hospitalId);
        //Hospital hospital = (Hospital) jsonBean.getData();
        //System.out.println("对象："+hospital);
        return jsonBean;
    }
    /** 
    * @Description: 模糊查询
    * @Param: [hospitalName] 
    * @return: com.platform.wechat.common.JsonBean 
    * @Author: MaYongQiang
    * @Date: 2021/7/28
    * @time: 14:36
    */
    @RequestMapping("vagueQuery")
    public JsonBean getVagueQuery(String hospitalName){
        //System.out.println(hospitalName);
        JsonBean jsonBean = hospitalService.vagueQuery(hospitalName);
        //System.out.println("进入模糊查询");
        return jsonBean;
    }

    /** 
    * @Description: 根据科室查询医院
    * @Param: [officesName] 
    * @return: com.platform.wechat.common.JsonBean 
    * @Author: guopeixin
    * @Date: 2021/7/31 10:31
    */
    @GetMapping("getHospitalInfo")
    public JsonBean getHospitalInfo(String officesName,String hospitalAddress, String hospitalName) {
       // System.out.println(officesName);
        JsonBean jsonBean = hospitalService.selectHospitalByofficesName(officesName , hospitalAddress, hospitalName);
        //System.err.println(jsonBean.getData() + "根据科室查询医院");
        return jsonBean;
    }


    /** 
    * @Description: 根据医院ID查询医院信息及科室
    * @Param: [hospitalId] 
    * @return: com.platform.wechat.common.JsonBean 
    * @Author: guopeixin
    * @Date: 2021/7/31 16:19
    */
    @GetMapping("getHospitalDetail")
    public JsonBean selectOfficesNameByHospitalId(Integer hospitalId, Integer chiefofficesId, Integer officesId, String hospitalAddress, String officesName, String hospitalName) {
        //System.err.println(hospitalId);
        JsonBean jsonBean = hospitalService.selectOfficesNameByHospitalId(hospitalId, chiefofficesId, officesId, hospitalAddress, officesName, hospitalName);
        //System.err.println(jsonBean.getData() + "根据医院ID查询医院信息及科室");
        return jsonBean;
    }


    /** 
    * @Description: 根据医院ID,科室名称查询一条信息
    * @Param: [hospitalId, officesName]
    * @return: com.platform.wechat.common.JsonBean 
    * @Author: guopeixin
    * @Date: 2021/8/1 16:27
    */
    @RequestMapping("getOneHospital")
    public JsonBean getOneHospital(Integer hospitalId, String officesName, Integer officesId, String hospitalAddress, String hospitalName) {
       // System.err.println(hospitalId+"**"+officesName+"**"+officesId);
        JsonBean jsonBean = hospitalService.selectOne(hospitalId, officesName, officesId, hospitalAddress, hospitalName);
        //System.err.println(jsonBean.getData() + "根据医院ID,科室ID查询一条信息");
        return jsonBean;
    }

    @RequestMapping("selectOneByONO")
    public JsonBean selectOneByONO(Integer hospitalId, Integer officesId) {
       // System.err.println(hospitalId+"**"+officesId);
        JsonBean jsonBean = hospitalService.selectOneByONO(hospitalId, officesId);
       // System.err.println(jsonBean.getData() + "根据医院ID,科室ID查询一条信息");
        return jsonBean;
    }

    @RequestMapping("getHospitalDistance")
    public JsonBean getHospitalDistance(Double longitude,Double latitude){
        System.err.println(longitude+"///////"+latitude);
        return hospitalService.insertHospitalDistance(longitude, latitude);
    }

    @RequestMapping("getHospitalSortByDistance")
    public JsonBean getHospitalSortByDistance(){
        return hospitalService.selectAllSortByDistance();
    }

}
